﻿using Stylet;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace LearnWPF.Pages
{
    public class PageTemplateViewModel : Screen
    {
        protected override void OnInitialActivate()
        {
            base.OnInitialActivate();
            InitDataList();
        }

        public void RoundButtonClick()
        {
            MessageBox.Show("RoundButtonClick");
        }

        public int ProgressValue { get; set; }


        public ObservableCollection<DataItem> DataList { get; set; }

        private void InitDataList()
        {
            DataList = new ObservableCollection<DataItem>()
            {
                new DataItem(){Title = "AAAAA",Age=10,IsChecked=true},
                new DataItem(){Title = "BBBBB",Age=20},
                new DataItem(){Title = "CCCCC",Age=30},
                new DataItem(){Title = "DDDDD",Age=40},
            };
        }      

        public void ShowList()
        {
            foreach (var item in DataList)
            {
                if (item.IsChecked)
                {
                    Debug.WriteLine($"{item.Title} is Checked!");
                }
            }
        }

        public class DataItem
        {
            public bool IsChecked { get; set; }
            public string Title { get; set; }
            public int Age { get; set; }
            public bool IsChild => Age < 12;

            public override string ToString()
            {
                return Title;
            }
        }
    }
}
